package com.cmit.upay.monitor.properties;

import lombok.Data;
import lombok.ToString;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@EnableConfigurationProperties
@Configuration
@ConfigurationProperties(prefix = "upay.monitor.mq")
@Data
@ToString
public class ActiveMQProperties {
    private List<String> jmxUrlList;
    private List<String> adminUrlList;

    private Boolean useJmx;

    private String jmxUrls;
    private String jmxUsername;
    private String jmxPassword;

    private String adminUrls;
    private String adminUsername;
    private String adminPassword;

    private String borkerName = "localhost";

    private String outputDir;
    private String outputFileType = "txt";

    private Boolean outputConsumer = true;
    private long consumerFileSize = 10 * 1024 * 1024;//10M

    private int pageSize;

    private String queues;
    private List<String> queuesList = new ArrayList<>();

    public void setJmxUrls(String jmxUrls) {
        this.jmxUrls = jmxUrls;
        this.jmxUrlList = Arrays.asList(jmxUrls.split(","));
    }

    public void setAdminUrls(String adminUrls) {
        this.adminUrls = adminUrls;
        this.adminUrlList = Arrays.asList(adminUrls.split(","));
    }

    public void setQueues(String queues) {
        this.queues = queues;
        if (!StringUtils.isEmpty(queues)) {
            queuesList = Arrays.asList(queues.split(","));
        }
    }

    public void setConsumerFileSize(long consumerFileSize) {
        this.consumerFileSize = consumerFileSize * 1024 * 1024;
    }
}
